// Vector

Assault.Vector = {}

// Add

function Assault.Vector.__add(A, B)
	if (type(A) != "table") then A = {X = A, Y = A} end
	if (type(B) != "table") then B = {X = B, Y = B} end
	
	// Return new
	
	return Assault.Vector:New(A.X + B.X, A.Y + B.Y)
end

// Unm

function Assault.Vector:__unm(A)
	return Assault.Vector:New(-A.X, -A.Y)
end

// Sub

function Assault.Vector.__sub(A, B)
	if (type(A) != "table") then A = {X = A, Y = A} end
	if (type(B) != "table") then B = {X = B, Y = B} end
	
	// Return new
	
	return Assault.Vector:New(A.X - B.X, A.Y - B.Y)
end

// Mul

function Assault.Vector.__mul(A, B)
	if (type(A) != "table") then A = {X = A, Y = A} end
	if (type(B) != "table") then B = {X = B, Y = B} end
	
	// Return new
	
	return Assault.Vector:New(A.X * B.X, A.Y * B.Y)
end

// New

function Assault.Vector:New(X, Y)
	local Table = {}
	
	// Meta table
	
	setmetatable(Table, self)
	
	// Index
	
	self.__index = self
	
	// Vector
	
	Table.X = X
	Table.Y = Y
	
	// Return table
	
	return Table
end

// Rotate around vector - (Foszor)

function Assault.Vector:VectorRotateAroundVector(Vec, Rotation)
	Vec = Vec:Vector3D()
	
	// Temp
	
	local Temp = self:Vector3D() - Vec
	
	// Len and ang
	
	local Len = Temp:Length()
	local Ang = Temp:Angle()
	
	// Adjust the yaw
	
	Ang.yaw = Ang.yaw - Rotation
	
	// Forward
	
	Temp = (Ang:Forward() * Len) + Vec
	
	// Save
	
	self.X = Temp.X
	self.Y = Temp.Y
end

// Get 3D

function Assault.Vector:Vector3D()
	return Vector(self.X, self.Y, 0)
end